package com.cloud.configure;

import com.cloud.common.constants.AuthBlankList;
import com.cloud.security.SecurityInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 功能描述: Spring_Security 权限框架
 *
 * @author yzj
 */
@Configuration
public class SecurityConfiguration implements WebMvcConfigurer {

    /**
     * 添加认证拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getSecurityInterceptor())
                // 指定该类拦截的URL
                .addPathPatterns("/**")
                // 过滤指定类的URL
                .excludePathPatterns(AuthBlankList.securityBlankList());
    }

    public SecurityInterceptor getSecurityInterceptor() {
        return new SecurityInterceptor();
    }

}
